SELECT INTO Statement |
您所在的位置:网站首页 › oracle select into from › SELECT INTO Statement |
The SELECT INTO statement retrieves values from one or more database tables (as the SQL SELECT statement does) and stores them in variables (which the SQL SELECT statement does not do). Caution: The SELECT INTO statement with the BULK COLLECT clause is vulnerable to aliasing, which can cause unexpected results. For details, see "SELECT BULK COLLECT INTO Statements and Aliasing". See Also: Oracle Database SQL Language Reference for the syntax of the SQL SELECT statement Topics Syntax Semantics Examples Related Topics Syntax select_into_statement ::= Description of the illustration select_into_statement.eps( bulk_collect_into_clause ::= , into_clause ::= , table_reference ::= ) select_item ::= Description of the illustration select_item.epsSee "function_call ::=". table_reference ::= Description of the illustration table_reference.epsSemantics select_into_statement DISTINCT or UNIQUE Causes the database to return only one copy of each set of duplicate rows selected. Duplicate rows are those with matching values for each select_item. These two keywords are synonymous. Restrictions on DISTINCT and UNIQUE The total number of bytes in all select_item expressions is limited to the size of a data block minus some overhead. This size is specified by the initialization parameter DB_BLOCK_SIZE. No select_item expression can contain a LOB column. ALL (Default) Causes the database to return all rows selected, including all copies of duplicates. * Selects all columns. subquery SQL SELECT statement (not a PL/SQL SELECT INTO statement). alias Another (usually short) name for the referenced column, table, or view. rest_of_statement Anything that can follow table_reference in the FROM clause in a SQL SELECT statement, described in Oracle Database SQL Language Reference. into_clause With this clause, the SELECT INTO statement retrieves one or more columns from a single row and stores them in either one or more scalar variables or one record variable. For more information, see "into_clause ::=". bulk_collect_into_clause With this clause, the SELECT INTO statement retrieves an entire result set and stores it in one or more collection variables. For more information, see "bulk_collect_into_clause ::=". select_item If the SELECT INTO statement returns no rows, PL/SQL raises the predefined exception NO_DATA_FOUND. To guard against this exception, select the result of the aggregate function COUNT(*), which returns a single value even if no rows match the condition. numeric_literal Literal of a numeric data type. schema Name of the schema that contains the table or view. Default: your schema. db_table_or_view Name of a database table or view. column Name of a column of db_table_or_view. * Selects all columns of db_table_or_view. sequence Name of a sequence. CURRVAL Current value in sequence. NEXTVAL Next value in sequence. alias Another (usually short) name for the referenced column, table, or view. table_reference Reference to a table or view for which you have the SELECT privilege, which is accessible when you run the SELECT INTO statement. schema Name of the schema that contains the table or view. Default: your schema. table Name of a database table. view Name of a database view. PARTITION partition or SUBPARTITION subpartition See Oracle Database SQL Language Reference. @dblink Database link, described in Oracle Database SQL Language Reference. Do not put space between @ and dblink. Examples Example 2-25, "Assigning Value to Variable with SELECT INTO Statement" Example 5-48, "SELECT INTO Assigns Values to Record Variable" Example 6-37, "ROLLBACK Statement" Example 6-38, "SAVEPOINT and ROLLBACK Statements" Example 6-43, "Declaring Autonomous Function in Package" Example 7-20, "Validation Checks Guarding Against SQL Injection" Example 12-16, "Bulk-Selecting Two Database Columns into Two Nested Tables" Example 12-17, "Bulk-Selecting into Nested Table of Records" Example 12-21, "Limiting Bulk Selection with ROWNUM, SAMPLE, and FETCH FIRST" Related Topics In this chapter: "Assignment Statement" "FETCH Statement" "%ROWTYPE Attribute" In other chapters: "Assigning Values to Variables with the SELECT INTO Statement" "Using SELECT INTO to Assign a Row to a Record Variable" "Processing Query Result Sets With SELECT INTO Statements" "SELECT INTO Statement with BULK COLLECT Clause" See Also: Oracle Database SQL Language Reference for information about the SQL SELECT statement |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |